package cn.kgc.projectmanagement.service;

import cn.kgc.projectmanagement.mapper.ProjectInfoMapper;
import cn.kgc.projectmanagement.pojo.ProjectInfo;
import cn.kgc.projectmanagement.pojo.ProjectInfoExample;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class ProjectInfoServiceImpl implements ProjectInfoService{
    @Resource
    ProjectInfoMapper mapper;

    @Override
    public PageInfo<ProjectInfo> projectlist(Integer status, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        ProjectInfoExample example=new ProjectInfoExample();
        if(status!=0){
            example.createCriteria().andStatusEqualTo(status);
        }
        PageInfo<ProjectInfo> pageInfo=new PageInfo<>(mapper.selectByExample(example));
        return pageInfo;
    }

    @Override
    public ProjectInfo getProject(Integer id) {
        ProjectInfo projectInfo=mapper.selectByPrimaryKey(id);
        return projectInfo;
    }

    @Override
    public int getUpdate(ProjectInfo projectInfo) {
        int result=mapper.updateByPrimaryKeySelective(projectInfo);
        return result;
    }
}
